//
//  InsuranceTabbarController.m
//  PhotoAnnotate
//
//  Created by Bassem El-Tamimi on 03.03.11.
//  Copyright 2011 ePapyrus GmbH. All rights reserved.
//

#import "InsuranceTabbarController.h"
#import "InsuranceViewController.h"
#import "InsuranceDataEntryViewController.h"
#import "InsuranceConditionsViewController.h"


@interface InsuranceTabbarController ()

@property (retain, readwrite, nonatomic) Insurance *insuranceData;

@end

@implementation InsuranceTabbarController
@synthesize insuranceData;



// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad 
{
    [super viewDidLoad];
	
	//[[UIApplication sharedApplication] setStatusBarHidden:YES];
	//[self setWantsFullScreenLayout:YES];
    
	self.insuranceData = [[[Insurance alloc] init] autorelease];
	
	InsuranceViewController *viewController1 = [[[InsuranceViewController alloc] initWithNibName:@"InsuranceViewController" bundle:nil] autorelease];
	InsuranceConditionsViewController *viewController2 = [[[InsuranceConditionsViewController alloc] initWithNibName:@"InsuranceConditionsViewController" bundle:nil] autorelease];
	InsuranceDataEntryViewController *viewController3 = [[[InsuranceDataEntryViewController alloc] initWithNibName:@"InsuranceDataEntryViewController" bundle:nil] autorelease];

	
	[self setViewControllers:[NSArray arrayWithObjects:viewController1, viewController2, viewController3, nil]];
	
	UITabBarItem *item1 = [[UITabBarItem alloc] initWithTitle:NSLocalizedString(@"INSURANCE_FEATURES_TAB_BAR_ITEM_TITLE", @"Features") image:[UIImage imageNamed:@"Conditions.png"] tag:1];	
	[viewController1 setTabBarItem:item1];
	[item1 release];
	UITabBarItem *item2 = [[UITabBarItem alloc] initWithTitle:NSLocalizedString(@"INSURANCE_CONDITIONS_TAB_BAR_ITEM_TITLE", @"Conditions") image:[UIImage imageNamed:@"paragraph.png"] tag:2];	
	[viewController2 setTabBarItem:item2];
	[item2 release];
	UITabBarItem *item3 = [[UITabBarItem alloc] initWithTitle:NSLocalizedString(@"INSURANCE_REQUEST_FORM_TAB_BAR_ITEM_TITLE", @"Request Form") image:[UIImage imageNamed:@"Form.png"] tag:3];	
	[viewController3 setTabBarItem:item3];
	[item3 release];
	
	[self setSelectedViewController:viewController1];
	
	[self setDelegate:self];

}

- (void)viewWillDisappear:(BOOL)animated
{
	[super viewWillDisappear:animated];
	[[UIApplication sharedApplication] setStatusBarHidden:NO];
	[self setWantsFullScreenLayout:NO];
}

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
{
	if ([viewController.nibName compare:@"InsuranceDataEntryViewController"] == NSOrderedSame) {
		[[UIApplication sharedApplication] setStatusBarHidden:NO];
		[self setWantsFullScreenLayout:NO];
		[viewController setWantsFullScreenLayout:NO];
	} else {
		[[UIApplication sharedApplication] setStatusBarHidden:YES];
		[self setWantsFullScreenLayout:YES];
		[viewController setWantsFullScreenLayout:YES];
	}
	return YES;
}

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc. that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
		
	self.insuranceData = nil;
}


- (void)dealloc {
    [super dealloc];
}


@end
